package com.ksyun.cloudhostalarmprocessing.controller;

import com.ksyun.cloudhostalarmprocessing.common.QueryRequest;
import com.ksyun.cloudhostalarmprocessing.common.QueryResponse;
import com.ksyun.cloudhostalarmprocessing.common.ResultSet;
import com.ksyun.cloudhostalarmprocessing.entity.vo.AlertDataVO;
import com.ksyun.cloudhostalarmprocessing.entity.vo.AlertVo;
import com.ksyun.cloudhostalarmprocessing.service.IAlertsService;
import com.ksyun.cloudhostalarmprocessing.service.Impl.AlertsServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 李厚航
 * @since 2024-05-07
 */
@RestController
@RequestMapping("/alerts")
public class AlertsController {
    @Autowired
    IAlertsService alertsService;

    @GetMapping("/getAlert/{page}/{size}")
    @CrossOrigin
    public ResultSet findAlert(@PathVariable("page")Integer page, @PathVariable("size") Integer size){
        Integer start  = (page - 1) * size;
        List<AlertVo> alert = alertsService.findAlert(start,size);
        return ResultSet.ok(alert);
    }
    @GetMapping("/count")
    @CrossOrigin
    public ResultSet getCount(){
        Integer count = alertsService.selectCount();
        return ResultSet.ok(count);
    }
}
